package com.learn.bean;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.flink.table.api.Schema;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class TestBean {

    String message;

    String status;

//    Integer l;
//
//    Long time;


    public static Schema schema(){

        Map<Class,String> map = new HashMap<>();
        map.put(String.class,"STRING");
        map.put(Integer.class,"INT");
        map.put(Long.class,"BIGINT");

        Schema.Builder builder = Schema.newBuilder();

        Field[] fields = TestBean.class.getDeclaredFields();

        for (Field field : fields) {
            builder.column(field.getName(),map.get(field.getType()));
        }

        return builder.build();

    }

    public static void main(String[] args) {
        TestBean.schema();
    }
}
